package com.liang.cloud.Service.impl;

import com.liang.cloud.Entity.ProductCategory;
import com.liang.cloud.Repository.ProductCategoryRepository;
import com.liang.cloud.Service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author: 余亮亮
 * @description: 类目service实现层
 * @create: 2019-12-27 18:58:37
 **/
@Service
@Transactional
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    ProductCategoryRepository repository;
    @Override
    public ProductCategory findOne(Integer categoryId) {
        return repository.findByCategoryId(categoryId);
    }

    @Override
    public List<ProductCategory> findAll() {
        return repository.findAll();
    }

    @Override
    public Page<ProductCategory> findAll(Pageable pageable) {
        return repository.findAll(pageable);
    }

    @Override
    public List<ProductCategory> findByCategoryTypeIn(List<Integer> categoryTypeList) {
        return repository.findByCategoryTypeIn(categoryTypeList);
    }

    @Override
    public ProductCategory sava(ProductCategory productCategory) {
        return repository.save(productCategory);
    }
}
